package com.lishe.lishe.lishe.module.me.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.LinkedList;

/**
 * Created by zhcasecom on 2017/8/17.
 */

public class PageAdapter extends FragmentPagerAdapter {
    LinkedList<Fragment> listFragments;
    String [] titles;
    public PageAdapter(LinkedList <Fragment>listFragments,String [] titles,FragmentManager fm) {
        super(fm);
        this.listFragments=listFragments;
        this.titles=titles;
    }

    @Override
    public Fragment getItem(int position) {
        return listFragments.get(position);
    }

    @Override
    public int getCount() {
        return listFragments.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }


    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if(titles==null){
            return super.getPageTitle(position);
        }
        return titles[position];
    }
}
